package org.rds.managedbeans;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.inject.Named;

import org.rds.controller.UserEJB;
import org.rds.model.Customer;
import org.rds.model.User;



/**
 * 
 */

/**
 * @author Dimitri Lebel
 *
 */
@ManagedBean
@Named(value = "UserMBean")
@RequestScoped
public class UserMBean {
	@EJB 
	private UserEJB userEJB;
	private User user ;
	private List<User> users;
	
	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}
	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}
	
	/**
	 * @return the users
	 */
	public List<User> getUsers() {
		users = userEJB.getAllUsers();
		return users;
	}
	/**
	 * @param users the users to set
	 */
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public UserMBean() {
		user = new Customer();
		users = new ArrayList<User>();
	}
	
	public void createUser(){
		userEJB.saveUser(user);
	}


	
}
